<extend name="Base/base" />
<block name='head'>
    <meta charset="utf-8">
    <link href="/Public/static/dropload/dropload.css" rel="stylesheet" />
    <!--<link href="/Public/Index/css/page.css" rel="stylesheet" />-->
    <link href="/Public/Index/css/plan_lists.css" rel="stylesheet" /> 
    <style>
        .plan_nr{margin-left:5px}
        .plan_nr{position: relative}
        .readFlag{width:7px;height:7px;border-radius: 50%;background: #F74339;display: inline-block;position: absolute;top:22px;left:-13px}
    </style>
</block>
<block name="content" > 
    <div class="main_plan_lists">
        <form action="{:U('lists')}" method="get">
            <div class="search_plans">
                <div class="search_left">
                    <i class="xiala">&#xe62f;</i>
                    <select name="plantype">
                        <option value='' selected>全部</option>
                        <foreach name="types" item="type">
                            <option value='{$type.type_id}' {$planType == $type['type_id'] ? 'selected' : ''}>{$type.type_name}</option>
                        </foreach>
                    </select>
                </div>
                <div class="search_right">
                    <i class="icon-search">&#xe600;</i>
                    <input type="text" name="name" class="search" style="padding:0" value="{$name}"/>
                </div>
                <input type="hidden" name="type" value="{$is_end}">
                <div class="search_button"><a class="searchBtn pointer"><span>搜索</span></a></div>
            </div>
        </form>
        <div class="plan_lists">
            <notempty name="lists">
                <foreach name="lists" item="plan" key="key">
                    <div class="list_pl">
                        <a href="{:U('show',array('id'=>$plan['plan_id'],'type'=>$is_end))}" title="{$plan.name}">
                            <dl class="plan_nr">
                                <if condition="$plan['noRead'] == 1">
                                    <span class="readFlag"></span>
                                </if>
                                <dt class="hang1 title_1">{$plan.sort}</dt>
                                <dd class="hang1"><span>{$plan.total_percent}%</span></dd>
                            </dl>
                        </a>
                        <dl>
                            <dt class="hang2">             
                                <img src="{$plan.head}" width="30px" style="border-radius: 50%;"/>
                                <span class="name">{$plan.manager}</span>
                            </dt>
                            <dd class="hang2">
                                <span class="gangzhu" data-id="{$plan.plan_id}" data-url="{:U('attentPlan')}" style=<if condition="$plan[gz] eq 1">"background:yellow"</if>>&#xe621;</span>
                            </dd>
                        </dl>
                        <div style="clear:both"></div>
                    </div>
                </foreach>
                <else />
                <div class="list_pl">
                    <dl>
                        <dt class="hang1 title_1">暂无数据</dt>
                    </dl>
                    <div style="clear:both"></div>
                </div>
            </notempty>
        </div>
    </div>
    <input type="hidden" id="url" value="{:U('dropload',array('type'=>$type))}">
    <input type='hidden' id='month' value='{$month|default=""}'>
    <input type="hidden" id="type" value="{$is_end}">

</block>
<block name="script">
    <script type="text/javascript" src="/Public/static/dropload/dropload.js" ></script>
    <script type="text/javascript" src="/Public/Index/js/plan.js"></script>
    <script type="text/javascript" src="/Public/Index/js/planNew.js"></script>
    <script type="text/javascript">
        $('.back').on('click', function () {
            location.href = $(this).attr('data-url')
        })

        $('body').on('click', '.gangzhu', function () {
            var plan_id = $(this).attr('data-id');
            var url = $(this).attr('data-url') + '?plan_id=' + plan_id;
            $.get(url, function (res) {
                console.log(res);
                layer.msg(res.msg);
                setTimeout("location.reload()", 2000);
            })
        })

        //搜索
        $('.searchBtn').on('click', function () {
            $('form').submit();
        })

        $(initSchedule())

        $(function () {
            p = 2;
            var dropload = $('.plan_lists').dropload({
                scrollArea: window,
                domDown: {
                    domClass: 'dropload-down',
                    domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
                    domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
                    domNoData: '<div class="dropload-noData">已无数据</div>'
                },
                loadDownFn: function (me) {
                    var plantype = $('select[name=plantype]').val();
                    var name = $('input[name=name]').val();
                    var url = $('#url').val() + '?p=' + p + '&type=' + $('#type').val() + '&month=' + $('#month').val() + '&plantype=' + plantype + '&name=' + name;
                    p++;
                    $.ajax({
                        url: url,
                        type: 'get',
                        success: function (res) {
                            console.log(res)
                            if (res.length > 0) {
                                var html = '';
                                for (var i = 0; i < res.length; i++) {
                                    html += '<div class="list_pl">';
                                    html += '<a href="/index.php/Index/Plan/show/id/' + res[i].plan_id + '/type/' + $('#type').val() + '" style="color: #333" title="' + res[i].name + '">';
                                    html += '<dl class="plan_nr">';
                                    if(res[i].noRead == 1){
                                        html += '<span class="readFlag"></span>';
                                    }
                                    html += '<dt class="hang1 title_1">' + res[i].sort + '</dt>';
                                    html += '<dd class="hang1"><span>' + res[i].total_percent + '%</span></dd></dl></a>';
                                    html += '<dl><dt class="hang2"><img src="' + res[i].head + '" style="width:30px;border-radius: 50%"/>';
                                    html += '<span class="name">' + res[i].manager + '</span></dt>';
                                    html += '<dd class="hang2"><span class="gangzhu" data-id="' + res[i].plan_id + '" data-url="/index.php/Index/Plan/attentPlan">&#xe621;</span></dd></dl>';
                                    html += '<div style="clear:both"></div></div>';
                                }
                                $('.plan_lists .list_pl:last').after(html);
                            } else {
                                me.noData();
                            }
                            me.resetload();
                        }
                    })
                }
            });
        })

    </script>
</block>






